package com.ag.utils;

public class PageUtils {
	public static <T> Page<T> convert(org.springframework.data.domain.Page<T> sourcePage) {
		if(sourcePage == null) return null;
		
		Page<T> page = new Page<T>();
		page.setCurrentPage(NumberUtils.isNotValid(sourcePage.getNumber()) ? 1: sourcePage.getNumber() + 1);
		page.setItems(sourcePage.getContent());
		page.setPageSize(sourcePage.getSize());
		page.setTotalCount(new Long(sourcePage.getTotalElements()).intValue());
		page.setTotalPage(sourcePage.getTotalPages());
		return page;
	};
}
